//logs.js
const util = require('../../utils/util.js')

Page({
  data: {
    toView:"icon",
    firsttop:"1000",
    

    logs: [],
    left:"1000px",
    top:"1000px",
    xldevation:5350,
    yldevation:-2450,
    xla:113410881,  
    yla:23019682,
    xpa:213 + 70 ,       
    ypa:674 + 40,
    xz:3.61 ,       
    yz:3.3,
    xpixel:0,
    ypixel:0,
    latitude:0,
    longitude:0,
    pchangex:596-662,
    pchangey:-532-146,
    cos:1238/1374,
    sin:596/1374
  },
  
  onLoad: function () {
    this.setData({
      logs: (wx.getStorageSync('logs') || []).map(log => {
        return util.formatTime(new Date(log))
      })
    })

    
    var top = this.data.firsttop;
    wx.pageScrollTo({
      scrollTop: top
      
    })
    console.log(top)
  },

  getlocation: function () {
    var page = this

    setInterval(function(){
      console.log("定位");

    wx.getLocation({
      success: function (res) {
        var pxz = ((res.longitude * 1000000 - page.data.xla + page.data.xldevation) / page.data.xz + page.data.xpa)+page.data.pchangex
        var pyz = (-(res.latitude * 1000000 - page.data.yla + page.data.yldevation) / page.data.yz + page.data.ypa) + page.data.pchangey
        page.setData({
          latitude: res.latitude,
          longitude: res.longitude,
          left:page.data.cos*pxz-page.data.sin*pyz+662-25+"px",
          top:page.data.cos*pyz+page.data.sin*pxz+146-50+"px",

          firsttop:page.data.cos * pyz + page.data.sin * pxz + 146 - 50,
          toView: "icon",
        })
        
        
        //控制台
        console.log(page.data.top),
        console.log(page.data.firsttop)
        
      },
      fail: function (res) {
        wx.showToast({
          title: "获取经纬度失败",
          icon: "none"
        })
      },
    })

    },1000)
    //滚动
    

  },
  openlocation: function () {
    var page=this
    wx.openLocation({
      latitude: page.data.latitude,
      longitude: page.data.longitude,
    })
  },
})
